
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

/*
 * ./first_drv on
 * ./first_drv off
 */

int main(int argc, char **argv)
{
	int fd;
	int val;

	fd = open("/dev/first_drv", O_RDWR);
	if(fd < 0)
	{
		printf("Can't open /dev/first_dev\n\r");
		return -1;
	}

	if(argc != 2)
	{
		printf("Usage: ./first_drv <on|off>");
		return -1;
	}

	if(strcmp(argv[1], "on") == 0)
	{
		val = 1;
	}
	else if(strcmp(argv[1], "off") == 0)
	{
		val = 0;
	}
	write(fd, &val, 4);
	return 0;
}



